<template>
  <div id="index">
    <!-- 这是首页
        <input type="text" name="" id="" @keydown.enter="enter"  >
        <div class="navi">
            <p @click="enter">商品</p>
        </div>
        <div class="list">
            <p @click="godetail">商品列表</p>
        </div> -->
    <div id="top">
      <span class="iconfont arrow_l">&#xe6bc;</span>
      <h2>小U商城</h2>
      <p>
        <span class="iconfont">&#xf0112;</span>
        <span class="iconfont">&#xe71e;</span>
        <i class="line"></i>
      </p>
    </div>
    <!--  标题 -->
    <header>
      <span class="iconfont">&#xe613;</span>
      <h1><img src="../../assets/images/logo.jpg" alt="" /></h1>
      <input type="text" v-model="keyword" class="iconfont" placeholder="按内容搜索" @keydown.enter="enterpush" >
      <span class="iconfont shopicon">&#xe663;</span>
    </header>
    <div id="nav_wrap">
      <nav>
        <span class="cur" 
          >推荐
          <i></i>
        </span>
        <span  @click="enter(item.id)"  v-for="(item,index) in catelist.slice(0, 5)" :key="index"  >{{item.catename}}</span>
      </nav>
      <p ><i class="iconfont">&#xe611;</i>分类</p>
    </div>
    <main>
      <!-- 广告栏 -->
      <div id="banner">
        <img :src="$pre+item.img" v-for="(item,index) in bannerlist.slice(0,1)" :key="index" />
      </div>
      <!-- 分类 -->
      <div id="classify">
        <p>
          <img src="../../assets/images/icon_1.jpg" alt="" />
          <span>限时秒杀</span>
        </p>
        <p>
          <img src="../../assets/images/icon_2.jpg" alt="" />
          <span>畅销商品</span>
        </p>
        <p>
          <img src="../../assets/images/icon_3.jpg" alt="" />
          <span>品质大牌</span>
        </p>
        <p>
          <img src="../../assets/images/icon_4.jpg" alt="" />
          <span>小U自营</span>
        </p>
        <p>
          <img src="../../assets/images/icon_5.jpg" alt="" />
          <span>积分商城</span>
        </p>
      </div>

      <div id="ad">
        <div class="left">
          <img src="../../assets/images/shop_bg1.png" alt="" />
          <span>限时秒杀</span>
          <i class="iconfont">查看更多&#xe601;</i>
          <b>每天零点场，好货秒不停</b>
          <p>
            <em>05</em>: <em>20</em>:
            <em>48</em>
          </p>
        </div>
        <div class="right">
          <p class="top">
            <img src="../../assets/images/shop_bg2.png" alt="" class="img" />
            <span>品牌上新</span>
            <b>九点整，抢大牌</b>
            <img src="../../assets/images/./mark_1.jpg" alt="" class="mark" />
          </p>
          <p class="bottom">
            <img src="../../assets/images/shop_bg3.png" alt="" class="img" />
            <span>日用好物</span>
            <b>愿君多采颉</b>
            <img src="../../assets/images/./mark_2.jpg" alt="" class="mark2" />
          </p>
        </div>
      </div>
      <!-- 双11尖货预购-->
      <div id="next">
        <div class="top">
          <span>双1尖货预购</span>
          <span>畅购全球</span>
        </div>
        <div class="bottom">
          <img src="../../assets/images/shop.jpg" alt="" />
          <img src="../../assets/images/shop.jpg" alt="" />
          <img src="../../assets/images/shop.jpg" alt="" />
          <img src="../../assets/images/shop.jpg" alt="" />
        </div>
      </div>
      <div id="goodslist">
        <div class="top">
          <p v-for="(item,index) in arr" :key="index" :class="type==index?'active':''" @click="changetype(index)">
            {{item}} 
          </p>
        </div>
        <div class="bottom">
          <p @click="goodsetail(item.id)" v-for="(item,index) in hortgoodslist[type] "  
          :key="index">
            <img :src="$pre+item.img" alt="">
            <span>
              <i>{{item.goodsname}}</i>
              <em>现价：￥ {{item.price}}</em>
              <del>原价：￥{{item.market_price}}</del>
              <b>立即抢购</b>
            </span>
          </p>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import {mapActions,mapGetters} from 'vuex'
export default {
  data(){
    return{
      keyword:"",
      type:0,
      arr:[
        "热门推荐",
        "上新推荐",
        "人气商品"
      ],
    }
  },
  methods: {
    enter(id) {
      this.$router.push("/shoppinglist2?num="+id+"&type=1");
    },
    enterpush(){
        this.$router.push("/shoppinglist?keywords="+this.keyword);
    },
    ...mapActions({
      reqChangeCate:"mainindex/reqChangeCate",
      reqChangeBanner:"banner/reqChangeBanner",
      reqChangeHortgoods:"hortgoods/reqChangeHortgoods"
    }),
    changetype(index){
      this.type=index
    }
  },
  computed:{
      ...mapGetters({
        catelist:"mainindex/list",
        bannerlist:"banner/list",
        hortgoodslist:"hortgoods/list"
      })
  },
  mounted(){
    this.reqChangeCate();
    this.reqChangeBanner();
    this.reqChangeHortgoods()
  }
};
</script>

<style  scoped >
/*头部*/
#top {
  height: 0.64rem;
  padding: 0.28rem 0.1rem 0.28rem 0.33rem;
  background-color: #ff6040;
  display: flex;
  color: #ffdfd8;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  left: 0;
  top: 0;
  z-index:1 ;
}
#top .arrow_l {
  font-size: 0.34rem;
}
#top h2 {
  font-size: 0.32rem;
  margin: 0 1.23rem 0 2.22rem;
}
#top p {
  height: 0.64rem;
  width: 1.75rem;
  display: flex;
  border: 1px solid #ff8a6f;
  box-sizing: border-box;
  border-radius: 0.64rem;
  align-items: center;
  position: relative;
}
#top p span {
  width: 50%;
  height: 100%;
  text-align: center;
  line-height: 0.64rem;
}
#top p .line {
  width: 1px;
  height: 0.38rem;
  position: absolute;
  left: 0.87rem;
  top: 0.13rem;
  background-color: #fff;
}
header {
  height: 0.64rem;
  width: 7.5rem;
  background: linear-gradient(to bottom, #ff6040, #ff674a, #ff7560);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.23rem 0 0.25rem;
   position: fixed;
  left: 0;
  top: 1.1rem;
  z-index:1 ;
}
header .iconfont {
  font-size: 0.46rem;
  color: #fff;
}
header .shopicon{
  margin-right: 0.5rem;
}
header h1{
    height: 0.64rem;
    width: 1.82rem;
    position: relative;
}
header h1 img {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}
header input {
  width: 3.4rem;
  height: 0.64rem;
  box-sizing: border-box;
  border: 1px solid #e6e6e6;
  padding: 0.22rem;
  border-radius: 0.1rem;
}
header input::placeholder {
  font-size: 0.24rem;
  color: #999999;
}
#nav_wrap {
  height: 0.76rem;
  background: linear-gradient(to bottom, #ff7b69, #ff8a7f);
  display: flex;
  padding-top: 0.18rem;
  box-sizing: border-box;
   position: fixed;
  left: 0;
  top: 1.74rem;
  z-index:1 ;
}
#nav_wrap nav {
  display: flex;
  width: 6.2rem;
  height: 0.56rem;
  justify-content: space-between;
  padding: 0 0.18rem 0 0.2rem;
  box-sizing: border-box;
  background: url(../../assets/images/line.jpg) no-repeat right top;
}
#nav_wrap nav span {
  color: #fff3f2;
  font-size: 0.26rem;
}
#nav_wrap nav span.cur {
  font-size: 0.3rem;
  margin-top: -0.05rem;
  font-weight: bold;
  position: relative;
}
#nav_wrap nav span.cur i {
  height: 0.04rem;
  position: absolute;
  width: 0.4rem;
  background-color: #fff;
  bottom: 0;
  left: 0.12rem;
  border-radius: 0.01rem;
}
#nav_wrap p {
  width: 1.4rem;
  color: #fff;
  text-align: center;
  font-size: 0.26rem;
  align-items: center;
}
#nav_wrap p span {
  vertical-align: middle;
  font-size: 0.26rem;
}
main {
  overflow: auto;
  width: 7.5rem;
  padding-bottom: 1.5rem;
  background-color: #fff;
  margin: auto;
  padding-top: 2.68rem;
}
main #banner img {
  width: 100%;
}
main #classify {
  height: 1.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.35rem;
  background-color: #fff;
}
main #classify p {
  display: flex;
  flex-direction: column;
  align-items: center;
}
main #classify p img {
  width: 0.6rem;
}
main #classify p span {
  margin-top: 0.13rem;
  font-size: 0.16rem;
}
main #ad {
  height: 3.9rem;
  box-sizing: border-box;
  display: flex;
  padding: 0.2rem;
  justify-content: space-between;
}
main #ad .left {
  position: relative;
}
main #ad .left img {
  height: 3.5rem;
}
main #ad .left span {
  font-size: 0.3rem;
  color: #85a642;
  position: absolute;
  left: 0.2rem;
  top: 0.2rem;
  font-weight: bold;
}
main #ad .left i {
  position: absolute;
  top: 0.26rem;
  right: 0.3rem;
  font-size: 0.2rem;
}
main #ad .left b {
  position: absolute;
  font-size: 0.18rem;
  left: 0.2rem;
  top: 0.7rem;
  color: #b4cd7e;
}
main #ad .left p {
  display: flex;
  color: #b4cd7e;
  justify-content: space-between;
  position: absolute;
  top: 1.1rem;
  left: 0.2rem;
  font-size: 0.22rem;
}
main #ad .left p em {
  width: 0.32rem;
  height: 0.36rem;
  background: linear-gradient(to bottom, #86a744, #afca78);
  font-size: 0.22rem;
  text-align: center;
  line-height: 0.36rem;
  color: #fff;
}
main #ad .right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
main #ad .right .top {
  width: 3.5rem;
  position: relative;
}
main #ad .right .top .img {
  width: 100%;
}
main #ad .right .top span {
  font-size: 0.3rem;
  color: #ff6040;
  position: absolute;
  left: 0.2rem;
  top: 0.2rem;
  font-weight: bold;
}
main #ad .right .top b {
  position: absolute;
  font-size: 0.18rem;
  left: 0.2rem;
  top: 0.7rem;
  color: #ffa592;
}
main #ad .right .top .mark {
  width: 1.2rem;
  position: absolute;
  left: 0.2rem;
  top: 1.1rem;
}
main #ad .right .bottom {
  width: 3.5rem;
  position: relative;
}
main #ad .right .bottom .img {
  width: 100%;
}
main #ad .right .bottom span {
  font-size: 0.3rem;
  color: #af40ff;
  position: absolute;
  left: 0.2rem;
  top: 0.2rem;
  font-weight: bold;
}
main #ad .right .bottom b {
  position: absolute;
  font-size: 0.18rem;
  left: 0.2rem;
  top: 0.7rem;
  color: #ca80ff;
}
main #ad .right .bottom .mark2 {
  width: 1.2rem;
  position: absolute;
  left: 0.2rem;
  top: 1.1rem;
}
main #next {
  height: 3rem;
}
main #next .top {
  height: 0.84rem;
  background-color: #fff;
  display: flex;
  align-items: center;
}
main #next .top span {
  font-size: 0.26rem;
  color: #a0a0a0;
  width: 50%;
  height: 100%;
  text-align: center;
  line-height: 0.84rem;
}
main #next .top span:nth-child(1) {
  font-size: 0.3rem;
  font-weight: bold;
  color: #ff6040;
}
main #next .bottom {
  height: 2.2rem;
  background-color: #fff;
  display: flex;
  padding: 0 0.2rem;
  justify-content: space-between;
}
main #next .bottom img {
  width: 1.6rem;
} 

main #goodslist{
  width: 6.9rem;
  margin-top: 0.6rem;
}
main #goodslist .top{
  width: 6.9rem;
  height: 0.6rem;
  display: flex;
  justify-content: space-around;
  align-items: center;
  color: orange;
  text-align: center;
}
main #goodslist .top p{
   width: 2.3rem;
    height: 0.6rem;
    line-height: 0.6rem;
    font-size: 0.34rem;
}
main #goodslist .top .active{
  background-color: orange;
  color: #fff;
}
main #goodslist .bottom{
  width: 6.9rem;
}
main #goodslist .bottom p{
  height: 3.0rem;
  width: 6.6rem;
  display: flex;
  justify-content: space-between;
  margin:0.2rem auto 0;
}

#goodslist .bottom p img{
  height: 3.0rem;
  width: 3rem;
}

#goodslist .bottom p span{
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-left:0.5rem ;
  box-sizing: border-box;
  font-size: 0.28rem;
  line-height: 0.42rem;
}

#goodslist .bottom  span i{
  margin-top: 0.6rem;
}
#goodslist .bottom  span em{
  color: #e63224;
}
#goodslist .bottom  span del{
  color: #dadada;
}

#goodslist .bottom  span b{
  display: block;
  height: 0.46rem;
  width: 1.34rem;
  background-color: orange;
  color: #fff;
  text-align: center;
  margin-top: 0.2rem;
}
/* main #goodslist p{

} */
 /* footer {
  width: 100vw;
  height: 1.65rem;
  background-color: #fff;
  display: flex;
  padding: 0.15rem 0.7rem 0;
  box-sizing: border-box;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  left: 0;
}
footer p {
  display: flex;
  flex-direction: column;
  text-align: center;
  font-size: 0.18rem;
  align-items: center;
  color: #a7a7a7;
}
footer p.cur {
  font-weight: bold;
  color: #ff6040;
}
footer p.cur .iconfont {
  color: #ff6040;
}
footer p .iconfont {
  color: #999;
  font-size: 0.4rem;
}
footer i {
  width: 2.68rem;
  height: 0.1rem;
  background-color: #000;
  position: absolute;
  bottom: 0.16rem;
  left: 2.6rem;
  border-radius: 0.05rem;
} */
</style>